package com.UKIT.airtickets.Service.Handlers

import android.content.Context
import androidx.test.core.app.ApplicationProvider
import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Test

import org.junit.Assert.*
import org.mockito.Mockito.mock

class AuthenticatorTest {

    @Test
    fun authenticate(){
        val context = mock(Context::class.java)

        val login = "Ushish"
        val password = "Lolhilol00."

        var authenticationSuccess = false

        val callbacks = object : AuthenticatorCallbacks {
            override fun onAuthenticationSuccess() {
                authenticationSuccess = true
            }

            override fun onAuthenticationFailure() {
                throw AuthenticationException("Authentication failed")
            }
        }

        val authenticator = Authenticator(context, callbacks)

        authenticator.authenticate(login, password)

        assertEquals(false, authenticationSuccess)
    }
    private class AuthenticationException(message: String) : Exception(message)
}
